﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for GroupProduct
/// </summary>
public class GroupProductDAL : BaseDAL
{
    public DataSet List(int pageIndex, int pageMax, int groupProductId, int groupParent, int isActive)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "@pageIndex", "@pageMax", "@groupProductId", "@GroupParent", "@IsActive" };
        object[] uspParaValue = new object[] { pageIndex, pageMax, groupProductId, groupParent, isActive };
        string uspName = "MiT_usp_groupproduct_listgroupproduct";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }
    public DataSet Detail(int groupProductId)
    {
        DataSet ds = new DataSet();
        ds = List(1, 1, groupProductId, 0, -1);
        return ds;
    }
    public DataSet Insert(string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        string urlFriendly = URLHelper.URLFriendly(groupProductName);
        string[] uspParaName = new string[] { "@GroupProductName", "@IsActive", "@GroupParent", "@Status", "@FriendlyURL" };
        object[] uspParaValue = new object[] { groupProductName, isActive, groupParent, status, urlFriendly };
        string uspName = "MiT_usp_groupProduct_insert";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }
    public DataSet Update(int groupProductId, string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        string urlFriendly = URLHelper.URLFriendly(groupProductName);
        string[] uspParaName = new string[] { "@GroupProductId", "@GroupProductName", "@IsActive", "@GroupParent", "@Status", "@FriendlyURL" };
        object[] uspParaValue = new object[] { groupProductId, groupProductName, isActive, groupParent, status, urlFriendly };
        string uspName = "MiT_usp_groupProduct_update";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }
    public DataSet UpdateStatusActive(int groupProductId, int isActive)
    {
        DataSet ds = new DataSet();
        string query = string.Format("update MiT_groupproducts set IsActive={0} where groupProductId={1};", isActive, groupProductId);
        ds = base.RunQuery(query);
        return ds;
    }
}